***************************
*** TOP PANEL, MARCH CPS **
***************************

*** COLUMNS 1,2 **

clear all 
set more off
cd "/Users/yasenov/Dropbox/mariel_boatlift/jhr_version/jhr_figures"
global folder /Users/yasenov/Dropbox/mariel_boatlift/revision_version/revision_data/

use $folder/aux_march.dta

keep if low_skilled == 1
keep if hisp == 0
keep if age >= 25 & age <= 59
keep if male == 1
keep if labforce == 2
drop if classwly == 10 | classwly == 13 | classwly == 14 
keep if logwage > 0

keep if metarea == 5000 | metarea == 4481 | metarea == 6840 | metarea == 7320 | metarea == 1920 | metarea == 5607

collapse (mean) logwage [pw=wtsupp], by(year metarea)
replace year = year - 1 

/* smoothing */
xtset metarea year
tssmooth ma logwage_sm = logwage, window(1 1 1)
drop logwage
rename logwage_sm logwage
*		*/

reshape wide logwage, i(year) j(metarea)
rename (logwage5000) (logwage_mia)

/* Borjas Synthetic Control */
gen logwage_bor = .512 * logwage4481 + .256 * logwage6840 + .232 * logwage7320
replace logwage_bor = 1.32*.512*logwage4481 + 1.32*.232*logwage7320 if year < 1976

keep year logwage_mia logwage_bor
rename (logwage_mia logwage_bor) (logwage_mia_column1_2 column1_2)  
tempfile edno
save `edno'

*** COLUMN 3 **
use $folder/aux_march.dta, clear

keep if low_skilled == 1
keep if hisp == 0
keep if age >= 25 & age <= 59
keep if male == 1
keep if labforce == 2
drop if classwly == 10 | classwly == 13 | classwly == 14 
keep if logwage > 0

collapse (mean) logwage [pw=wtsupp], by(year metarea)
replace year = year - 1 

reshape wide logwage, i(year) j(metarea)
rename (logwage5000) (logwage_mia)

/* Borjas Synthetic Control */
gen logwage_bor = .512 * logwage4481 + .256 * logwage6840 + .232 * logwage7320
replace logwage_bor = 1.32*.512*logwage4481 + 1.32*.232*logwage7320 if year < 1976

keep year logwage_mia logwage_bor
rename (logwage_mia logwage_bor) (logwage_mia_column3 column3)
tempfile dve
save `dve'

*** COLUMNS 4,5 **
use $folder/aux_march.dta, clear

keep if age >= 19 & age <= 65
keep if low_skilled == 1
keep if hispan != 300
keep if labforce == 2
drop if classwly == 10 | classwly == 13 | classwly == 14 

collapse (mean) logwage [pw=wtsupp], by(year metarea)
replace year = year - 1

reshape wide logwage, i(year) j(metarea)

rename logwage5000 logwage_mia_column4_5
gen column5 = .323 * logwage520 + .371 * logwage1640 + .185 * logwage5560 + .121 * logwage8280
gen column4 = 1.14*(.271 * logwage5602 + .525 * logwage5607 + .074 * logwage1280)

keep year logwage_mia_column4_5 column4 column5

tempfile tri
save `tri'

***************
***************

clear
use `edno'
merge 1:1 year using `dve', nogen
merge 1:1 year using `tri', nogen

rename (logwage_mia_column1_2 logwage_mia_column3 logwage_mia_column4_5 column1_2 column3 column4 column5) ///
	(logwage1 logwage2 logwage3 logwage4 logwage5 logwage6 logwage7)

reshape long logwage, i(year) j(city)

estimates clear
drop if year == 1980

/* Columns 1,2 */
preserve
gen pre1 = year >=1976 & year <=1978
gen pre2 = year >=1972 & year <=1975
gen post1 = year >=1981 & year <=1983
gen post2 = year >=1984 & year <=1985
gen post3 = year >=1986 & year <=1988
gen post4 = year >=1989 & year <=1991

keep if city == 1 | city == 4
gen mia = city == 1
gen synthetic = city == 4

gen miapre1 = mia*pre1
gen miapre2 = mia*pre2
gen miapost1 = mia*post1
gen miapost2 = mia*post2
gen miapost3 = mia*post3
gen miapost4 = mia*post4

reg logwage miapost* i.year i.city if year > 1976, robust // this is column 1
estimates store one
reg logwage miapre* miapost* i.year i.city, robust  // this is column 2
estimates store two
restore

/* Column 3 */
preserve
gen pre1 = year >=1976 & year <=1978
gen pre2 = year >=1972 & year <=1975
gen post1 = year >=1981 & year <=1983
gen post2 = year >=1984 & year <=1985
gen post3 = year >=1986 & year <=1988
gen post4 = year >=1989 & year <=1991

keep if city == 2 | city == 5
gen mia = city == 2
gen synthetic = city == 5

gen miapre1 = mia*pre1
gen miapre2 = mia*pre2
gen miapost1 = mia*post1
gen miapost2 = mia*post2
gen miapost3 = mia*post3
gen miapost4 = mia*post4

reg logwage miapre* miapost* i.year i.city, robust  // this is column 3
estimates store three
restore

/* Column 4 */
preserve
gen pre1 = year >=1976 & year <=1978
gen pre2 = year >=1972 & year <=1975
gen post1 = year >=1981 & year <=1983 
gen post2 = year >=1984 & year <=1985
gen post3 = year >=1986 & year <=1988
gen post4 = year >=1989 & year <=1991

keep if city == 3 | city == 6
gen mia = city == 3
gen synthetic = city == 6

gen miapre1 = mia*pre1
gen miapre2 = mia*pre2
gen miapost1 = mia*post1
gen miapost2 = mia*post2
gen miapost3 = mia*post3
gen miapost4 = mia*post4

reg logwage miapre* miapost* i.year i.city, robust  // this is column 5
estimates store four
restore

/* Column 5 */
preserve
gen pre1 = year >=1976 & year <=1978
gen pre2 = year >=1972 & year <=1975
gen post1 = year >=1981 & year <=1983 
gen post2 = year >=1984 & year <=1985
gen post3 = year >=1986 & year <=1988
gen post4 = year >=1989 & year <=1991

keep if city == 3 | city == 7
gen mia = city == 3
gen synthetic = city == 7

gen miapre1 = mia*pre1
gen miapre2 = mia*pre2
gen miapost1 = mia*post1
gen miapost2 = mia*post2
gen miapost3 = mia*post3
gen miapost4 = mia*post4

reg logwage miapre* miapost* i.year i.city, robust  // this is column 6
estimates store five
restore

*********************
*********************
*********************

estimates table one two three four five, keep(m*) b(%4.3f) se(%4.3f) stats(r2 N)
estimates table one two three four five, keep(m*) b(%4.3f) star stats(r2 N)
